<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>清除缓存 - Fun-Sport 管理后台</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .container {
      background: white;
      border-radius: 16px;
      padding: 48px;
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
      max-width: 500px;
      width: 100%;
    }

    h1 {
      font-size: 28px;
      margin-bottom: 16px;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      text-align: center;
    }

    p {
      color: #666;
      line-height: 1.6;
      margin-bottom: 24px;
      text-align: center;
    }

    .info-box {
      background: #f5f7fa;
      border-left: 4px solid #409eff;
      padding: 16px;
      margin-bottom: 24px;
      border-radius: 4px;
    }

    .info-box p {
      text-align: left;
      margin: 0;
      font-size: 14px;
    }

    .button {
      width: 100%;
      padding: 16px;
      font-size: 16px;
      font-weight: 600;
      border: none;
      border-radius: 8px;
      cursor: pointer;
      margin-bottom: 12px;
      transition: all 0.3s;
    }

    .button-primary {
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      color: white;
    }

    .button-primary:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }

    .button-secondary {
      background: #f5f7fa;
      color: #606266;
    }

    .button-secondary:hover {
      background: #e4e7ed;
    }

    .status {
      text-align: center;
      margin-top: 20px;
      padding: 12px;
      border-radius: 8px;
      display: none;
    }

    .status.success {
      background: #f0f9ff;
      color: #67c23a;
      border: 1px solid #b3e19d;
    }

    .status.error {
      background: #fef0f0;
      color: #f56c6c;
      border: 1px solid #fbc4c4;
    }

    .status.show {
      display: block;
    }

    .cache-list {
      background: #f9f9f9;
      padding: 16px;
      border-radius: 8px;
      margin: 16px 0;
      font-size: 14px;
      color: #666;
    }

    .cache-item {
      padding: 8px 0;
      border-bottom: 1px solid #eee;
    }

    .cache-item:last-child {
      border-bottom: none;
    }

    .cache-key {
      font-weight: 600;
      color: #333;
    }

    .cache-value {
      color: #999;
      word-break: break-all;
    }
  </style>
</head>
<body>
  <div class="container">
    <h1>🔧 清除缓存</h1>
    <p>如果遇到登录或数据加载问题，请清除浏览器缓存</p>

    <div class="info-box">
      <p><strong>当前缓存数据：</strong></p>
      <div class="cache-list" id="cacheList">
        <div class="cache-item">
          <div class="cache-key">token:</div>
          <div class="cache-value" id="tokenValue">未设置</div>
        </div>
        <div class="cache-item">
          <div class="cache-key">userInfo:</div>
          <div class="cache-value" id="userInfoValue">未设置</div>
        </div>
      </div>
    </div>

    <button class="button button-primary" onclick="clearCache()">
      清除所有缓存
    </button>

    <button class="button button-secondary" onclick="goToLogin()">
      返回登录页
    </button>

    <div id="status" class="status"></div>
  </div>

  <script>
    // 显示当前缓存
    function displayCache() {
      const token = localStorage.getItem('token')
      const userInfo = localStorage.getItem('userInfo')
      
      document.getElementById('tokenValue').textContent = token 
        ? token.substring(0, 30) + '...' 
        : '未设置'
      
      document.getElementById('userInfoValue').textContent = userInfo || '未设置'
    }

    // 清除缓存
    function clearCache() {
      try {
        // 清除所有 localStorage
        localStorage.clear()
        
        // 清除所有 sessionStorage
        sessionStorage.clear()
        
        // 显示成功消息
        showStatus('success', '✅ 缓存清除成功！请返回登录页重新登录。')
        
        // 更新显示
        displayCache()
        
        // 3秒后自动跳转到登录页
        setTimeout(() => {
          goToLogin()
        }, 3000)
      } catch (error) {
        showStatus('error', '❌ 清除失败：' + error.message)
      }
    }

    // 显示状态消息
    function showStatus(type, message) {
      const status = document.getElementById('status')
      status.className = 'status ' + type + ' show'
      status.textContent = message
    }

    // 跳转到登录页
    function goToLogin() {
      window.location.href = '/'
    }

    // 页面加载时显示当前缓存
    displayCache()
  </script>
</body>
</html>

